<!DOCTYPE HTML>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width,user-scalable=no">
		<title>双旦</title>
		<meta name="keywords" content="狮吼,狮吼直播,手游直播,双投屏直播" />
		<meta name="description" content="狮吼 - 4亿手游玩家的直播平台、狮吼是游戏多旗下手游直播平台，支持双投屏直播的移动端平台，边玩边播，分享快乐！狮吼直播，随时随地录屏直播，语音弹幕独特玩法，各路主播游戏大神齐聚；电竞赛事、综艺娱乐、户外精彩，一切改变尽在 狮吼- 4亿手游玩家的直播平台。" />
		<link rel="stylesheet" href="static/css/base.css" />
		<link rel="stylesheet" href="static/css/style.css" />
		<script src="static/js/jquery-3.1.0.min.js"></script>
		<script src="static/js/dropLoad.js"></script>
		<script src="static/js/util.js"></script>

	</head>

	<body style=" background:url(static/img/bg4.jpg) no-repeat; background-size:100%; background-attachment: fixed;padding-bottom:22%;">

		<div class="wrap commonWrap">
			<!-- 评论 -->
			<div class="common">
				<div class="headerGu">
					<img src="static/img/bg5.jpg" />
					<div class="commonMenu">
						<div class="commonTab">
							<a id="a_new" class="curr" onclick="showTab(1);">最新</a>
							<a id="a_hot" onclick="showTab(2);">最热</a>
						</div>
					</div>
				</div>
				<div class="line">
					<div class="nav">
						<input placeholder="快来留言吧~" id="msg" />
						<a class="spend" onclick="sendMsg();"><img src="static/img/spend.png" /></a>
					</div>
					<ul class="list" id="ul_list" style="display: none;">
					</ul>
					<ul class="list" id="ul_list_new">
					</ul>
					<a class="more" style="width:100%; height:50px;">查看更多祝福</a>
				</div>

			</div>

			<div class="footer">
				<ul>
					<li>
						<a href="index.html"><img src="static/img/tab1.png" /></a>
					</li>
					<li>
						<a href="phb.html"><img src="static/img/tab2.png" /></a>
					</li>
					<li>
						<a><img src="static/img/tab3curr.png" /></a>
					</li>
				</ul>
			</div>

	</body>

</html>
<script>
	var util;
	var userId = '244269';
	var activityId = '3532';
	var pageNow1 = 0;
	var pageNow2 = 0;

	$(function() {
		util = new Util();
		var dropLoad = new DropLoad();
		loadCommonList();

		$(".more").click(util.clickTouch(), function() {
			loadCommonList();
			pageNow1++;
		});

		//滑动加载
		dropLoad.dropLoad('#ul_list', function() {
			pageNow1++;
			loadCommonList1();
		});
		dropLoad.dropLoad('#ul_list_new', function() {
			pageNow2++;
			loadCommonList2();
		});
	});

	//加载祝福墙
	function loadCommonList() {
		loadCommonList1();
		loadCommonList2();
	}

	function loadCommonList1() {
		var url = util.forumUrl + "/forum/query";
		var param = {
			"activityId": activityId,
			"pageSize": 4,
			"pageNum": pageNow1,
			"from_user_id": userId,
			"auditStatus": 2,
			"orderType": 2
		};
		util.requestRemoteDataJson(url, param, function(result) {
			console.log(result)
			$('#ul_list').html('');
			util.logResult(result);
			if(util.parseResult(result, 'errorCode') == 0) {
				var common_str = '';
				var dataResult = util.parseResult(result, 'result');
				var commonList = util.parseResult(dataResult, 'list');
				//console.log("留言数="+commonList.length);

				var userIdStr = "";
				for(var i = 0; i < commonList.length; i++) {
					userIdStr = userIdStr + commonList[i].uid;
					if(i < commonList.length - 1) {
						userIdStr = userIdStr + ",";
					}
				}
				var infoMap = getEditorBetch(userIdStr);

				$.each(commonList, function(index, obj) {
					var uidKey = obj.uid;
					var avatar = (infoMap[uidKey] == undefined || infoMap[uidKey].avatar == undefined) ? "" : infoMap[uidKey].avatar;
					var nick_name = (infoMap[uidKey] == undefined || infoMap[uidKey].nick_name == undefined) ? "" : infoMap[uidKey].nick_name;
					var fabulousStatus = obj.fabulousStatus;
					var create_time = obj.create_time;
					create_time = create_time.substr(5, 5) + ' ' + create_time.substr(11, 5);
					var fabulousImg = '';
					if(fabulousStatus) {
						fabulousImg = '<img src="static/img/yizan.png" />';
					} else {
						fabulousImg = '<img src="static/img/zan.png"/ onclick="fabulous(' + obj.uid + ',' + obj.id + ');">';
					}
					common_str += '<li>' +
						'	<p class="listTitle"><span>' + obj.content + '</span><a>' + fabulousImg + '</a></p>' +
						'	<p class="listFont">' +
						'		<a><em><img src="' + avatar + '"/></em><i>' + nick_name + '</i>' + create_time + '</a>' +
						'		<span>积赞：' + obj.fabulous_count + '</span>' +
						'	</p>' +
						'</li>';

				});
				$('#ul_list').html(common_str);
			}
		});
	}

	function loadCommonList2() {
		var url = util.forumUrl + "/forum/query";
		var param2 = {
			"activityId": activityId,
			"pageSize": 4,
			"from_user_id": userId,
			"auditStatus": 2,
			"orderType": 1,
			"pageNum": pageNow2,
		};
		util.requestRemoteDataJson(url, param2, function(result) {
			$('#ul_list_new').html('');
			util.logResult(result);
			if(util.parseResult(result, 'errorCode') == 0) {
				var common_str = '';
				var dataResult = util.parseResult(result, 'result');
				var commonList = util.parseResult(dataResult, 'list');
				console.log("留言数2=" + commonList.length);

				var userIdStr = "";
				for(var i = 0; i < commonList.length; i++) {
					userIdStr = userIdStr + commonList[i].uid;
					if(i < commonList.length - 1) {
						userIdStr = userIdStr + ",";
					}
				}
				var infoMap = getEditorBetch(userIdStr);

				$.each(commonList, function(index, obj) {
					var uidKey = obj.uid;
					var avatar = (infoMap[uidKey] == undefined || infoMap[uidKey].avatar == undefined) ? "" : infoMap[uidKey].avatar;
					var nick_name = (infoMap[uidKey] == undefined || infoMap[uidKey].nick_name == undefined) ? "" : infoMap[uidKey].nick_name;
					var fabulousStatus = obj.fabulousStatus;
					var create_time = obj.create_time;
					create_time = create_time.substr(5, 5) + ' ' + create_time.substr(11, 5);
					var fabulousImg = '';
					if(fabulousStatus) {
						fabulousImg = '<img src="static/img/yizan.png" />';
					} else {
						fabulousImg = '<img src="static/img/zan.png"/ onclick="fabulous(' + obj.uid + ',' + obj.id + ');">';
					}
					common_str += '<li>' +
						'	<p class="listTitle"><span>' + obj.content + '</span><a>' + fabulousImg + '</a></p>' +
						'	<p class="listFont">' +
						'		<a><em><img src="' + avatar + '"/></em><i>' + nick_name + '</i>' + create_time + '</a>' +
						'		<span>积赞：' + obj.fabulous_count + '</span>' +
						'	</p>' +
						'</li>';

				});
				$('#ul_list_new').html(common_str);
			}
		});
	}

	//发送留言
	function sendMsg() {

		var msg = $('#msg').val();
		var uid = userId;
		if(uid == '' || uid == null || uid == 0) {
			window.location.href = 'shihoutv://route?jump_type=120';
			return;
		}
		if(msg == '') {
			alert('请输入留言内容');
			return;
		}
		var url = util.forumUrl + "/forum/add?activityId=" + activityId + "&uid=" + uid + "&content=" + msg;

		util.requestRemoteDataPost(url, null, function(result) {
			util.logResult(result);

			if(util.parseResult(result, 'errorCode') != 0) {
				alert(util.parseResult(result, 'errorDescription'));
				$('#msg').val('');
			}
			if(util.parseResult(result, 'errorCode') == 0) {
				$('#msg').val('');
				alert('留言成功!');
				loadCommonList();
			}
		});
	}

	//点赞
	function fabulous(toUid, commonId) {
		var uid = userId;
		if(uid == '' || uid == null || uid == 0) {
			window.location.href = 'shihoutv://route?jump_type=120';
			return;
		}
		var url = util.forumUrl + "/forum/fabulous?activityId=" + activityId + "&uid=" + uid + "&toUid=" + toUid + "&id=" + commonId;
		util.requestRemoteDataPost(url, null, function(result) {
			util.logResult(result);
			if(util.parseResult(result, 'errorCode') == 0) {
				alert('点赞成功!');
				loadCommonList();
			}
			if(util.parseResult(result, 'errorCode') != 0) {
				alert(util.parseResult(result, 'errorDescription'));
			}
		});
	}

	//切换最新最热
	function showTab(type) {
		if(type == 1) {
			$('#a_new').addClass('curr');
			$('#a_hot').removeClass();

			$('#ul_list').hide();
			$('#ul_list_new').show();

		} else if(type == 2) {

			$('#a_new').removeClass();
			$('#a_hot').addClass('curr');

			$('#ul_list').show();
			$('#ul_list_new').hide();
		}
	}

	//批量获取用户头像和名称 
	function getEditorBetch(uidStr) {
		var url = util.reportUrl + "/user_info";
		var result = {};
		var param = {
			uids: uidStr
		};
		util.sendRequest(url, param, "get", false, function(data) {
			result = data.result;
		});

		return result;
	}
</script>